<ul class="categories">
    <?php
    if (!empty($items)) {
        $count_categories = count($items);
        foreach ($items as $key => $item) {
            if ($key == 0) {
                $value = 'first';
            } elseif ($key == $count_categories) {
                $value = 'last';
            } else {
                $value = '';
            }
            ?>
            <li class="htooltip <?php echo $value ?>">
                <div class="div_2">
                    <a href="<?php echo $this->createUrl('/site/list', array('id' => $item->id))?>">
                        <div class="div_2">
                            <div class="list_bg"></div>
                            <?php echo $item['name'];?>
                            <span class="category_arrow">
                            </span>
                        </div>
                    </a></div>
            </li>
        <?php
        }
    }
    ?>
</ul>